//
//  STNavigationController.m
//  赛拓
//
//  Created by 王磊 on 7/28/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STNavigationController.h"

@interface STNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation STNavigationController

+ (void)initialize {
    
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20] ,NSForegroundColorAttributeName: ST_NAVI_COLOR}];
    //    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:HZS_NAVI_IMAGE] forBarMetrics:UIBarMetricsDefault];
    
    //    [[UINavigationBar appearance] setTintColor:HZS_FDFDFD_COLOR];
    
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.interactivePopGestureRecognizer.delegate = self;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.childViewControllers.count > 0) {
        
        [viewController.navigationItem setHidesBackButton:true];
        
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemLeftOffsetWithTarget:self action:@selector(backItemTap) image:@"Safari-Forward" highImage:@"Safari-Forward"];
        
        //        viewController.hidesBottomBarWhenPushed = true;
        
    }else {
        
        //        viewController.hidesBottomBarWhenPushed = false;
    }
    
    [super pushViewController:viewController animated:animated];
}
- (void)backItemTap {
    
    [self popViewControllerAnimated:true];
}
- (UIViewController *)childViewControllerForStatusBarStyle{
    return self.topViewController;
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    // 手势何时有效 : 当导航控制器的子控制器个数 > 1就有效
    return self.childViewControllers.count > 1;
}


@end
